#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=100009;
ll m,cnt[N];
struct Num{
    ll v,c;
    bool operator<(const Num&x)const{
        return c>x.c||c==x.c&&v<x.v;
    }
};
set<Num> s;
void input(){
    cin>>m;
}
void solve(){
    for(ll i=1;i<=m;i++){
        ll op,val;
        scanf("%lld %lld",&op,&val);
        if(op==1){
            if(cnt[val]) s.erase((Num){val,cnt[val]});
            cnt[val]++;
            s.insert((Num){val,cnt[val]});
        }
        else if(cnt[val]){
            s.erase((Num){val,cnt[val]});
            cnt[val]--;
            s.insert((Num){val,cnt[val]});
        }
        if(s.empty()) printf("1\n");
        else printf("%lld\n",s.begin()->v);
    }
}
int main(){
    freopen("mode.in","r",stdin);
    freopen("mode.out","w",stdout);
    input();
    solve();
    return 0;
}
